<?php 
	include '../../connect.php';
	if(!isset($_SESSION))
	session_start();
	$sb=isset($_REQUEST["submit"]) ? "Đăng nhập" : "";
		if($sb=="Đăng nhập")
		{	
		$user=$_REQUEST["email001"];	
		$pass=md5($_REQUEST["matkhau001"]);
	$query="select * from thanhvien where Email='".$user."' and  MatKhau='".$pass."'";
	$result=mysql_query($query,$con);
	
	if(mysql_num_rows($result)>0)
	{
		$row = mysql_fetch_array($result);
		$email=$row['Email'];
		$pass=$row['MatKhau'];
		$ten=$row['HoTen'];
		$id=$row['ThanhVienID'];
		$quyen=$row['Quyen'];
		$_SESSION["quyen"]=$quyen;
		$_SESSION["email"]=$email;
		$_SESSION["id"]=$id;
		$_SESSION["kiemtradangnhap"]=1;
		$_SESSION["hoten"]=$ten;
		if($_SESSION["quyen"]==1){
					$_SESSION["emailadmin"]=$email;
					$_SESSION["successadmin"]=true;
					$_SESSION['hotenadmin']=$ten;	
					$_SESSION['matkhauadmin']=$pass;
		}
		 header("location:../../index.php");
	}
	else
	{
		?>
    <script language="javascript">
	window.location="../../index.php";
	</script>
    <?php
		
	}

	}
	else
	{
?>
 <script language="javascript">
	window.location="../../index.php";
	</script>
    <?php }?>